/*
 * COPYRIGHT:	2010 Christopher Smith, licenced under the GNU GPL v2; see COPYING in the top level directory
 * PROJECT:		sdedit
 * FILE:		subclswinbase.cpp
 * PURPOSE:		base class for subclassed windows
 *				
 */

class SubClassedWindowBase : public ClassedWindowBase
{
	WNDPROC PreviousWndProc;

protected:
	virtual void Init() override
	{
		PreviousWndProc = (WNDPROC)SetWindowLongPtr(Wnd, GWLP_WNDPROC, reinterpret_cast<ULONG_PTR>(&ClassedWindowBase::ClassedWndProc));

		ClassedWindowBase::Init();
	}

	virtual BOOLEAN UseDialogProcessing() override
	{
		return FALSE;
	}

	virtual LRESULT RecieveMessage(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
	{
		if(msg == WM_NCDESTROY)
			SetWindowLongPtr(Wnd, GWLP_WNDPROC, (ULONG_PTR)PreviousWndProc); //since this object won't survive long enough to process any more messages

		return CallWindowProc(PreviousWndProc, wnd, msg, wparam, lparam);
	}
};